home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 November
/
Chip_2004-11_cd1.bin
/
zkuste
/
dolby
/
download
/
dvdlab
/
DVDlabProRC2b.exe
/
{app}
/
Extras
/
Script
/
fade.talk
< prev
next >
Wrap
Text File
|
2004-03-22
|
3KB
|
116 lines
/* Linear Fade 1.0
by Oscar, 12 Dec 2003
To run this: DROP the Script from Assets to the Object in Menu.
this example creates a simple Linear Fade on any object
You can choose the direction
Note: because of the bitmap merging, the text will become not-editable after you apply this
*/
// Get the current menu and selected object when you drag and drop script
// Note: if testing from Script editor make sure you have just one menu opened on desktop,
// in such case the MenuGetCurSel will return currently opened menu
menu = MenuGetCurSel()
// VTS menu 1..255, VMG menu 10001..10255
// show the current menu on top of all others
MenuActivate(menu)
object= ObjectGetCurSel(menu)
if (object==0) then
print "No object Selected"
end
endif
type = LoadInteger("FadeType",0)
input "Direction:Vertical Bottom->Top|Horizontal Right->Left|Vertical Top->Bottom|Horizontal Left->Right",type //"CHECK:/FILE:/COLOR:/Combo:item1|item2...
//allow cancel
if bCancelInput then
trace "Cancelled"
end
endif
// save grad type to registry
SaveInteger("FadeType",type)
//get the image buffer from object and store it in buffer 1
ImgGrabObject(1,menu,object) // imgNum = temporary image buffer 1,2 or 3
imgW = ImgGetWidth(1)
imgH = ImgGetHeight(1)
//vertical
steps = imgH
//horizontal
if (type==1 | type==3) then
steps = imgW
endif
// one of the parameter in equation has to be float or else the result will be integer
// we will make the steps float number.
ca = 255.0/FLOAT(steps)
// if the other dirrection, make it negative (from 255 +(-ca) to 00)
if type>1 then
ca=-ca
endif
// trace is same as print, but it will appear only in the Output window in editor
trace "Steps =",steps, "ca=",ca
// this is interpreter so it is slow!
// show some progress or else people will see nothing happening for while
ProgressBar(0,imgH,"Building Linear Alpha Mask")
// loop through each pixel and draw the Alpha channel
// we have to combine the new gradient alpha with any existing alpha on the object
// if type = 0,1 we go AA=0 to 255,if 2,3, then we go the other way from AA=255 to 0
if (type==0 | type==2) then
// VERTICAL *******************************
AA=0
if type>1 then
AA=255
endif
for y=1 to imgH
AA=AA+ca
ProgressSetPos(y)
for x=1 to imgW
mix = ImgGetA(1,x,y)//,AA)
mix = MIN(mix,AA)
ImgSetA(1,x,y,mix )
next x
next y
else
// HORIZONTAL **************************
for y=1 to imgH
AA=0
if type>1 then
AA=255
endif
ProgressSetPos(y)
for x=1 to imgW
AA=AA+ca
mix = ImgGetA(1,x,y)
mix = MIN(mix,AA)
ImgSetA(1,x,y,mix)
next x
next y
endif
// now put the img buffer 1 into the object!
ImgSetToObject(1,menu,object)
// remove any shadow
ObjectSetShadow(menu,object,0,0)